<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box1 {
            width: 20px;
            height: 20px;
            background: red;
            float: left;
        }

        .box2 {
            width: 20px;
            height: 20px;
            background: orange;
            float: left;
            margin: 0 5px;
        }

        .box3 {
            width: 20px;
            height: 20px;
            background: blue;
            float: left;
        }
        header{
            width: 100%;
            height: 50px;
        }
    </style>
</head>

<body>
    <header>
        <div class="box1" onclick="hong()">

        </div>
        <div class="box2" onclick="ju()">

        </div>
        <div class="box3" onclick="lan()">

        </div>
    </header>
    <table border="1" cellspacing=0 width=500 >
        <tr>
            <th>新闻</th>
            <th>电影</th>
            <th>娱乐</th>
            <th>体育</th>
        </tr>
    </table>
</body>

</html>
<script>
    var body = document.querySelector("body")
    var tab = document.querySelector("table")
    console.log(body);
    function hong() {
        body.style.background = "red"
        tab.style.background = "orange"
        
    }
    function ju() {
        body.style.background = "orange"
        tab.style.background = "blue"
    }
    function lan() {
        body.style.background = "blue"
        tab.style.background = "red"
    }
</script>